<div class="funcbar">
<span class="add"><i class="fa fa-plus"></i> 新增</span>
<span class="edit"><i class="fa fa-pencil"></i> 编辑</span>
<span class="menu"><i class="fa fa-puzzle-piece"></i> 设置菜单</span>
<span class="del"><i class="fa fa-minus"></i> 删除</span>
<span class="print"><i class="fa fa-print"></i> 打印</span>
<span class="detail"><i class="fa fa-bars"></i> 详细</span>
<span data-toggle="collapse" data-target="#roleS"> <i class="fa fa-search-plus"></i> 查询</span>
</div>
<div id="roleS" class="searchbar panel panel-collapse collapse" role="tabpanel" aria-expanded="true">
<form class="searchform" role="form">
<div class="line" >
<div class="col-245 input-group">
<span class="input-group-addon">角色名称</span><input type="text" class="form-control" name="role_name" placeholder="模糊查询">
</div>
<div class="col-245 input-group">
<span class="input-group-addon">角色标志</span><input type="text" class="form-control" name="role_sign" placeholder="模糊查询">
</div>
</div>
<div class="text-center" >
<input type="hidden" name="page" value="1">
<button  type="button" data-toggle="collapse" data-target="#roleS">关闭</button> 
<button  type="reset" class="button" >清空</button> 
<button  type="button" class="searchbtn" >查询</button> 
</div>
</form>
</div>
<div id="roleD" class="data-list">
<table class="table table-hover">
<thead>
<tr>
<th field="role_id"><input type="checkbox" data-target="role_id" class="selectAll"></th>
<th field="role_name">角色名称</th>
<th field="role_sign">角色标识</th>
<th field="remark">备注</th>
<th field="gmt_create">创建时间</th>
<th field="gmt_modified">修改时间</th></tr>
</thead>
<tbody>

</tbody>
</table>
</div>
<div class="pagination">
</div>
<!-- 新增模态框（Modal） -->
<div class="modal fade" id="roleI" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="#app" aria-hidden="true"></div>
<!-- 修改模态框（Modal） -->
<div class="modal fade" id="roleU" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="#app" aria-hidden="true">
</div>
<!-- 角色菜单模态框（Modal） -->
<div class="modal fade" id="roleM" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="#app" aria-hidden="true">
</div>
<!-- 详细模态框（Modal） -->
<div class="modal fade" id="Rdetial" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="#app" aria-hidden="true">
	<div class="modal-panel">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title">
					角色详细
				</h4>
			</div>
			<div class="modal-body">
				<form>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">角色名称</span>
						<input type="text" class="form-control" disabled name="role_name">
					</div>
					<div class="right-48  input-group">
						<span class="input-group-addon">角色标识</span>
						<input type="text" class="form-control" disabled name="role_sign" >
						
					</div>
				</div>
				<div class="line">
					<div class="input-group">
						<span class="input-group-addon">备注</span>
						<div class="ta-outline"><textarea rows="3" disabled name="remark"></textarea></div>
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">创建人</span>
						<input class="form-control" disabled name="user_id_create"type="text">
					</div>
					<div class="right-48  input-group">
						<span class="input-group-addon">创建时间</span>
						<input type="text" class="form-control" disabled name="gmt_create">
					</div>
				</div>
				<div class="line">
					<div class="left-48 input-group">
						<span class="input-group-addon">最近修改人</span>
						<input type="text" class="form-control" disabled name="user_id_modify">
					</div>
					<div class="right-48 input-group">
						<span class="input-group-addon">最近修改时间</span>
						<input type="text" class="form-control" disabled name="gmt_modified">
					</div>
				</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
<script>


$(document).ready(function(){

	//标签页
	_ptab = $("#roleI").getParentTab();
	
	_ptab.on('click',".add",function(){
		m = getMenuByPermit('admin:role:add');
		$("#roleI").load(m.component);
		$("#roleI").modal('show');
	});
	
	_ptab.on('click',".edit",function(){
		 m = getMenuByPermit('admin:role:edit');
		 x = $("#roleD input[name='role_id']:checked");
		
		if(x.length>=1 && m){
			$("#roleU").load(m.component,'',getData(m.url,'role_id='+x.val(),function(res){$("#roleU").fillDetailData(res);}));
			$("#roleU").modal('show');
		}else{
			messageBox("请先勾选要编辑的角色记录。","操作提示");
		}
	});
	_ptab.on('click',".del",function(){
		 m = getMenuByPermit('admin:role:del');
		 x = $("#roleD input[name='role_id']:checked");
		
		if(x.length>=1 && m){
			_p = $(this).getParentTab();
			data = "t="+new Date();
			for(i=0;i<x.length;i++){
				data += "&role_id="+$(x[i]).val();
			}
			getData(m.url,data,function(res){
				if(res.code==RESP_SUCCESS){
					messageBox(res.msg,"操作提示");
					m = getMenuByPermit('admin:role');
					getData(m.url,_p.find("div.searchbar form").serialize(),
					function(res){ _p.fillListData(res); });
				}
			});
			
		}else{
			messageBox("请先勾选要删除的角色记录。","操作提示");
		}
	});
	_ptab.on('click',".menu",function(){
		m = getMenuByPermit('admin:role:menu');
		x = $("#roleD input[name='role_id']:checked");
		
		if(x.length>=1 && m){
			_p = $("#roleM");
			$("#roleM").load(m.component,'',getData(m.url,'role_id='+x.val(),function(res){
				if(res.code==RESP_SUCCESS && res.data){
					_p.find("input[name='role_id']").val(x.val());
					_tree = _p.find(".ztree");
					$.fn.zTree.init($(_tree),multiMenuTree,res.data);
				}
			}));
			$("#roleM").modal('show');
		}else{
			messageBox("请先勾选要设置菜单的角色记录。","操作提示");
		}
	});
	_ptab.on('click',".detail",function(){
		 m = getMenuByPermit('admin:role:get');
		 x = $("#roleD input[name='role_id']:checked");
		
		if(x.length>=1 && m){
			getData(m.url,'role_id='+x.val(),function(res){$("#Rdetial").fillDetailData(res);});
			$("#Rdetial").modal('show');
		}else{
			messageBox("请先勾选要查看详细的角色记录。","操作提示");
		}
	});
 });
</script>